# Contributor: James Bowes <jbowes@repl.ca>
# Contributor: Jan Segre <jan@segre.in>
# Contributor: Lars Kuhtz <lakuhtz@gmail.com>
# Contributor: Duncan Bellamy <dunk@denkimushi.com>
# Maintainer: Duncan Bellamy <dunk@denkimushi.com>
pkgname=rocksdb
pkgver=7.9.2
pkgrel=1
pkgdesc="persistent key-value store for fast storage environments"
url="https://rocksdb.org"
arch="all"
license="Apache-2.0 OR GPL-2.0-only"
depends_dev="bzip2-dev gflags-dev liburing-dev lz4-dev snappy-dev zlib-dev zstd-dev"
makedepends="$depends_dev bash cmake linux-headers perl samurai"
subpackages="$pkgname-dev $pkgname-doc"
options="!check" #tests are excluded from release builds
source="$pkgname-$pkgver.tar.gz::https://github.com/facebook/rocksdb/archive/v$pkgver.tar.gz
	10-support-busybox-install.patch
	11-shared-liburing.patch
	20-ppc64le-determine-platform.patch
	30-toku_time.patch
	40-no-powerpc-mcpu.patch
	50-include-cstdint.patch
	"

build() {
	cmake -B build \
		-DCMAKE_BUILD_TYPE=MinSizeRel \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DFAIL_ON_WARNINGS=OFF \
		-DWITH_BZ2=ON \
		-DWITH_SNAPPY=ON \
		-DWITH_LZ4=ON \
		-DWITH_ZSTD=ON \
		-DPORTABLE=ON \
		-DWITH_TESTS=OFF \
		-GNinja

	cmake --build build
	DEBUG_LEVEL=0 make gen-pc
}

package() {
	DESTDIR="$pkgdir" cmake --install build
	rm  "$pkgdir"/usr/lib/librocksdb.a
	install -Dm644 rocksdb.pc "$pkgdir"/usr/lib/pkgconfig/rocksdb.pc
	install -Dm644 COPYING "$pkgdir"/usr/share/licenses/$pkgname/COPYING
	install -Dm644 LICENSE.Apache "$pkgdir"/usr/share/licenses/$pkgname/LICENSE.Apache
	mkdir -p "$pkgdir"/usr/share/doc
	cp -a docs "$pkgdir"/usr/share/doc/$pkgname
	install -Dm644 README.md "$pkgdir"/usr/share/doc/$pkgname/README.md
	install -Dm644 HISTORY.md "$pkgdir"/usr/share/doc/$pkgname/HISTORY.md
}

sha512sums="
9cf2a359cedb21ca70fc921e54f19c406fd9aa2a739ad1627842fad2dec0e7dedbfe52aa8e85fbfbe7005c00ca1e7e7013f728d4d9938f3cebdf794504b431cb  rocksdb-7.9.2.tar.gz
fa98c289b465808c1bdda390d891d6430bb65096c39d2c327f7a82cdae1eeba8f3a47c6434eb4988b0c0c25d0e4900e92da28afe67c71b0b112b38b9a9f58887  10-support-busybox-install.patch
1a483fee936944088f694df0e809646986fe6c4224c2fe93c25f0b754f31dc1b98e1731cfa2732187c967663d8434f592f1b7cd7c6baba61362793f59f1ed6fa  11-shared-liburing.patch
835e7bb5e8e76aa264d7dbe55d44a01af4bcec7e61fc0aa8be173d28e302e9b368da064bd4b4a0020fa97bd46a51f3d8fc015db8a4af37890e0ba7924eb01ed0  20-ppc64le-determine-platform.patch
bdc68bce07eb488d86de6e607eadf1abfc543a3a2b2c57f3d25f8e278b8d6b3e943de6a51d60762b629d38c26080bdfad3d0e205429c0e777d0ca3aadee37259  30-toku_time.patch
56ea6c77c5bd920707de790869136cbf5bc12167c630d6ee523ceff5da91310c36d6b141a657856704139d93af6f47cf0e989744b10f4db92bcc48a8e2d66f41  40-no-powerpc-mcpu.patch
1d1838ceb84519cde3bcb5147147481aee2c8a0034f5c64731f6cea6f46e17b5bf9e1d97ca75b759613312560e70c7539744b52f8091550b6259f3b36c3b8d82  50-include-cstdint.patch
"
